l = [1, 2, 2, 1, 2, 2, 1, 4, 5, 6]
print(l)
# 对列表中每一个元素加1

for i in range(len(l)):
    l[i] = l[i] + 1

print(l)

# 列表推导式：对循环的一种简写, 将结果构建成一个新的列表

l2 = [i + 1 for i in l]

print(l2)

print("=" * 100)

# 对列表中的元素做处理，奇数乘2，偶数加1
l3 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print(l3)

for i in range(len(l3)):
    # 算术运算符比比较运算符的优先级高
    if l3[i] % 2 == 1:
        l3[i] = l3[i] * 2
    else:
        l3[i] = l3[i] + 1

print(l3)

print("=" * 100)

l3 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print(l3)
# if简写

age = 2
print('已成年') if age >= 18 else print("未成年")

# 列表推导式
l4 = [i * 2 if i % 2 == 1 else i + 1 for i in l3]

print(l4)
